]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
StContainer: Account for floating-point imprecision when sorting actors
authorOwen W. Taylor <otaylor@fishsoup.net>
Mon, 7 Mar 2011 20:31:55 +0000 (15:31 -0500)
committerOwen W. Taylor <otaylor@fishsoup.net>
Tue, 15 Mar 2011 19:41:07 +0000 (15:41 -0400)
When we compare the boxes for two actors, they may appear to overlap
by a small amount because of floating-point imprecision. Allow for
up to 0.1 pixel overlap when determining what children are in the
focus direction from the currently focused actor.

https://bugzilla.gnome.org/show_bug.cgi?id=644134

src/st/st-container.c

index 24430d040b96e7e779b6dccbf61b8ec01c94ff56..403da55737ca1793b68c39172d6e8fbf4a28bc3b 100644 (file)
@@ -445,33 +445,35 @@ filter_by_position (GList            *children,
       clutter_actor_get_allocation_box (child, &cbox);
 
       /* Filter out children if they are in the wrong direction from
-       * @rbox, or if they don't overlap it.
+       * @rbox, or if they don't overlap it. To account for floating-
+       * point imprecision, an actor is "down" (etc.) from an another
+       * actor even if it overlaps it by up to 0.1 pixels.
        */
       switch (direction)
         {
         case GTK_DIR_UP:
-          if (cbox.y2 > rbox->y1)
+          if (cbox.y2 > rbox->y1 + 0.1)
             continue;
           if (cbox.x1 >= rbox->x2 || cbox.x2 <= rbox->x1)
             continue;
           break;
 
         case GTK_DIR_DOWN:
-          if (cbox.y1 < rbox->y2)
+          if (cbox.y1 < rbox->y2 - 0.1)
             continue;
           if (cbox.x1 >= rbox->x2 || cbox.x2 <= rbox->x1)
             continue;
           break;
 
         case GTK_DIR_LEFT:
-          if (cbox.x2 > rbox->x1)
+          if (cbox.x2 > rbox->x1 + 0.1)
             continue;
           if (cbox.y1 >= rbox->y2 || cbox.y2 <= rbox->y1)
             continue;
           break;
 
         case GTK_DIR_RIGHT:
-          if (cbox.x1 < rbox->x2)
+          if (cbox.x1 < rbox->x2 - 0.1)
             continue;
           if (cbox.y1 >= rbox->y2 || cbox.y2 <= rbox->y1)
             continue;